<?php


namespace App\Http\Model;


use Illuminate\Support\Facades\DB;

class PayException extends Base
{
    protected $table = "pay_exception";

    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    //记录一条异常数据
    public function add($data)
    {
        $result = DB::table($this->table)->insert($data);
        return $result;
    }

    //获取当前用户的异常记录
    public function getByUserId($userId)
    {
        $rows = DB::table($this->table)->where('user_id', $userId)->get();
        return json_decode(json_encode($rows), true);
    }

    //获取当前用户的异常记录数量
    public function getExceptionCountByUserId($userId)
    {
        return DB::table($this->table)->where('user_id', $userId)->count();
    }
}